package com.common.core;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.HandlerMethod;

import com.base.core.mvc.web.BaseExceptionController;

import feign.FeignException;
import feign.codec.DecodeException;

/**
 * 全局异常处理
 * @author user
 *
 */
@RestControllerAdvice
public class FeignExceptionController extends BaseExceptionController {

    @ExceptionHandler(DecodeException.class)
    public Object handlerDecodeException(HandlerMethod handler, DecodeException e) {
        return response(messageParse(e.getMessage()), handler, e.getCause());
    }
    
    @ExceptionHandler(FeignException.class)
    public Object handlerFeignException(HandlerMethod handler, FeignException e) {
    	return response(messageParse("远程服务调用异常"), handler, e);
    }

}
